<?php
  if (isset($_POST['url']) && isset($_POST['height']))
  { 
    set_time_limit(0);

    $url = trim($_POST['url']);
    $height = trim($_POST['height']);
    $filePath ='uploads/tempdoc/'. md5($url).time().'.pdf';
    if (is_file($filePath)) 
    { 
      exit($filePath); 
    }
//    var_dump($_POST);exit;
    //如果不加这句就会报错“Fatal: [Errno 2] No such file or directory; did you install phantomjs?”,详情参考http://mengkang.net/87.html
    putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs");
//      $command = "phantomjs phantomjs.js {$url} {$filePath}";
      $command = "phantomjs myhtmltopdf.js {$url} {$filePath} {$height}";
      @exec($command);

    exit($filePath); 
  } 
?> 
